import 'package:flutter/material.dart';
import 'package:module/index_page.dart';

import 'const.dart';

class Login extends StatefulWidget {
  const Login({super.key});

  @override
  State<Login> createState() => _LoginState();
}

class _LoginState extends State<Login> {
  final _Controller1 = TextEditingController();
  final _Controller2 = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          SizedBox(
            height: mScreenHeight * 0.02,
          ),
          Container(
            height: mScreenHeight * 0.06,
            padding: const EdgeInsets.only(left: 10),
            decoration: BoxDecoration(
                // color: Colors.pink[100],
                borderRadius: BorderRadius.circular(10),
                border: Border.all(width: 1, color: Color(0xFFDDEAFB))),
            child: TextField(
              controller: _Controller1,
              decoration: const InputDecoration(
                border: InputBorder.none,
                hintText: '用户名',
              ),
            ),
          ),
          SizedBox(
            height: mScreenHeight * 0.065,
          ),
          Container(
            height: mScreenHeight * 0.06,
            padding: EdgeInsets.only(left: 10),
            decoration: BoxDecoration(
                // color: Colors.pink[100],
                borderRadius: BorderRadius.circular(10),
                border: Border.all(width: 1, color: Color(0xFFDDEAFB))),
            child: TextField(
              controller: _Controller2,
              decoration: const InputDecoration(
                border: InputBorder.none,
                hintText: '密码',
              ),
            ),
          ),
          SizedBox(
            height: mScreenHeight * 0.065,
          ),
          Column(
            children: [
              GestureDetector(
                onTap: () {
                  if (_Controller1.text == name &&
                      _Controller2.text == password) {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) {
                      return IndexPage();
                    }));
                  } else {
                    print('222');
                    // print(name);
                    // print(password);
                  }
                },
                child: Container(
                    width: double.infinity,
                    height: mScreenHeight * 0.065,
                    decoration: BoxDecoration(
                        color: Color(0xFF2B88EB),
                        borderRadius: BorderRadius.circular(10)),
                    child: Center(
                        child: Text(
                      '登录',
                      style: TextStyle(color: Colors.white, fontSize: 18),
                    ))),
              ),
              Container(alignment: Alignment.bottomRight, child: Text('忘记密码？'))
            ],
          )
        ],
      ),
    );
  }
}
